package org.deadline.service.user;

import java.util.List;
import org.deadline.model.user.SystemMailMessage;
import org.deadline.repository.user.SystemMailMessageRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class SystemMailMessageServiceImpl implements SystemMailMessageService {

	@Autowired
    SystemMailMessageRepository systemMailMessageRepository;

	public long countAllSystemMailMessages() {
        return systemMailMessageRepository.count();
    }

	public void deleteSystemMailMessage(SystemMailMessage systemMailMessage) {
        systemMailMessageRepository.delete(systemMailMessage);
    }

	public SystemMailMessage findSystemMailMessage(Long id) {
        return systemMailMessageRepository.findOne(id);
    }

	public List<SystemMailMessage> findAllSystemMailMessages() {
        return systemMailMessageRepository.findAll();
    }

	public List<SystemMailMessage> findSystemMailMessageEntries(int firstResult, int maxResults) {
        return systemMailMessageRepository.findAll(new org.springframework.data.domain.PageRequest(firstResult / maxResults, maxResults)).getContent();
    }

	public void saveSystemMailMessage(SystemMailMessage systemMailMessage) {
        systemMailMessageRepository.save(systemMailMessage);
    }

	public SystemMailMessage updateSystemMailMessage(SystemMailMessage systemMailMessage) {
        return systemMailMessageRepository.save(systemMailMessage);
    }
}
